package com.scau.phradmin.business.user.controller;

import com.scau.phradmin.business.user.service.impl.UserServiceImpl;
import com.scau.phradmin.domain.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/user")

@RestController
public class UserController {

    @Autowired
    private UserServiceImpl userService;

    @GetMapping("/selectAll")
    public Object selectAll(@RequestParam("pages") int pages){
        return userService.selectAll(pages);
    }

    @GetMapping("/selectByTel")
    public Object selectById(@RequestParam("tel") String tel)
    {
        return userService.selectByTel(tel);
    }

    @PostMapping("/edit")
    public boolean edit(User user){
        return userService.edit(user);
    }

    @PostMapping("/add")
    public boolean add(User user){
        return userService.add(user);
    }

    @PostMapping("/delete")
    public boolean delete(@RequestParam("tel") String tel){
        return userService.delete(tel);
    }
}
